import request from '@/utils/request'
import { resetRouter, removeToken } from '../router'

export function login(data) {
  return request({
    url: '/public/login/web',
    // url: '/login',
    method: 'post',
    data
  })
}

export function getInfo() {
  return request({
    url: '/user/personal/message',
    method: 'get'
    // params: {
    //   id: 1
    // }
  })
}

// export function logout() {
//   return request({
//     url: '/vue-element-admin/user/logout',
//     method: 'post'
//   })
// }

export function resetToken() {
  return new Promise(resolve => {
    removeToken() // must remove  token  first
    resetRouter()
    resolve()
  })
}

export function updateInfo(data) {
  return request({
    url: '/user/personal/message',
    method: 'put',
    data
  })
}

export function resetpsw(oldPassword, newPassword) {
  return request({
    url: '/user/personal/password',
    method: 'put',
    params: {
      oldPassword,
      newPassword
    }
  })
}

export function activateUser(id) {
  return request({
    url: '/user/administer/users/activation',
    method: 'put',
    id
  })
}

